"""
输入：
a,1,5
b,1,3
c,3,5

输出：
b c
"""
from mode import *


class Solution:
    def maxTaxiEarnings(self, n: int, rides: List[List[int]]):
        tempRides = []
        for _, start, end in rides:
            profit = (1.0 - (end - start) / 10) * (end - start)
            temp = [_, start, end, profit]
            tempRides.append(temp)
        print(tempRides)

        ans = []
        maxSum = 0

        def dfs(vis, tempAns, sum, idx):
            global maxSum, ans

            if idx == len(tempRides):
                if sum > maxSum:
                    maxSum = sum
                    ans = tempAns
                return

            name, u, v, p = tempRides[idx]
            print(name, u, v, p)
            flag = True
            for i in range(u, v):
                if vis[i]:
                    flag = False
                    break
            if flag:
                for i in range(u, v):
                    vis[i] = True

                dfs(vis, tempAns + [name], p + sum, idx + 1)
                for i in range(u, v):
                    vis[i] = False
            dfs(vis, tempAns, sum, idx + 1)

        vis = [False for _ in range(6)]
        dfs(vis, [], 0, 0)
        return " ".join(ans)

if __name__ == "__main__":
    """
    a,1,5
    b,1,3
    c,3,5
    p = (1.0 - (5 - 1) / 10 ) * (5-1) = 2.4 
    
    """
    A = Solution()
    print(A.maxTaxiEarnings(n=3, rides=[['a', 1, 5], ['b', 1, 3], ["c", 3, 5]]))
    # print(A.maxTaxiEarnings(n=20, rides=[[1, 6, 1], [3, 10, 2], [10, 12, 3], [11, 12, 2], [12, 15, 2], [13, 18, 1]]))
